<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>新闻中心</title>
		<link rel="stylesheet" href="../../plugin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="../../css/utils.css" />
		<link rel="stylesheet" type="text/css" href="../../css/index.css" />
		<script src="../../plugin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../plugin/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			.news-list {
				border-bottom: 2px solid #f2f2f2;
			}
			
			.industry-news .news-list:last-child,
			.company-news .news-list:last-child {
				border-bottom: 2px solid #f2f2f2;
			}
			
			.news-title {
				color: #000;
				margin-bottom: 20px;
			}
			
			.news-list-detail-content {
				color: #000;
			}
			
			.news-list-detail-time {
				color: #999;
			}
		</style>
	</head>

	<body>
		<div class="layui-fluid">
			<div class="layui-row header-row">

			</div>
			<div class="client-us">
				<div class="pageBg">
					<div class="pageBg2">
						<div class="pageBg3">
							<h3>新闻中心</h3>
							<p>News Center</p>
						</div>
					</div>
				</div>
				<div class="client-container">
					<div class="limit-width layui-row">
						<div class="company-news layui-col-md6">
							<div class="news-title">
								<p>公司新闻</p>
							</div>
							<div id="companyNews">

							</div>

						</div>
						<div class="industry-news layui-col-md6">
							<div class="news-title">
								<p>行业新闻</p>
							</div>
							<div id="industryNews">

							</div>
						</div>
					</div>
					<div id="newsPage" class="limit-width"></div>

				</div>

			</div>

			<div class="footer-nav">

			</div>

	</body>
	<script src="../../utils/api/index.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../utils/common/index.js" type="text/javascript" charset="utf-8"></script>

</html>
<script type="text/javascript">
	layui.use('laypage', function() {
		var laypage = layui.laypage;
		newList(1, 10);

		function newList(currPage, pageSize) {
			$.post(requestUrl.baseUrl + requestUrl.apiUrl.newsList, {
				page: currPage,
				limit: pageSize
			}, function(data) {
				if(data.code == 0) {
					var list = data.page.list
					var count = data.page.totalCount;
					$('#companyNews,#industryNews').empty();
					for(var i = 0; i < list.length; i++) {
						var title = list[i].title;
						var createTime = list[i].createTime.substring(0, 10);
						var type = list[i].type;
						var id = list[i].id;
						getImage(id)
						if(type == '公司新闻') {
							$('#companyNews').append('<div class="news-list layui-row" id="' + id + '">' +
								'<div class="news-list-img layui-col-md3">' +
								'<img src="" />' +
								'</div>' +
								'<div class="news-list-detail layui-col-md9">' +
								'	<div class="news-list-detail-content">' + title + '</div>' +
								'<div class="news-list-detail-time">' + createTime + '</div>' +
								'</div>' +
								'</div>')
						} else {
							$('#industryNews').append('<div class="news-list layui-row" id="' + id + '">' +
								'<div class="news-list-img layui-col-md3">' +
								'<img src="" />' +
								'</div>' +
								'<div class="news-list-detail layui-col-md9">' +
								'	<div class="news-list-detail-content">' + title + '</div>' +
								'<div class="news-list-detail-time">' + createTime + '</div>' +
								'</div>' +
								'</div>')
						}
					}

					laypage.render({
						elem: 'newsPage',
						count: count,
						limit: pageSize,
						curr: currPage,
						theme: '#0070c0',
						layout: ['limit', 'prev', 'page', 'next', 'count'],
						jump: function(obj, first) {
							if(!first) {
								newList(obj.curr, obj.limit);
							}
						}
					});
				}
			})
		}

		$('.limit-width').on('click', '.news-list ', function() {

			var id = $(this).attr('id')
			location.href = requestUrl.httpUrl + 'html/aboutUs/newsDetail.html?id=' + id
		})

		function getImage(id) {
			$.post(requestUrl.baseUrl + requestUrl.apiUrl.getImage, {
				recordId: id,
				attachType: 'NEWS_TITLE_PIC_1803'
			}, function(data) {
				if(data.code == 0 && data.list.length > 0) {
					$('#'+ id).find('img').attr('src', data.list[0].url)
				}
			})
		}

	});
</script>